package com.wyd.sort;


/**
 * 冒泡排序
 * */
public class BubbleSort implements SortInterface {
    @Override
    public int[] sort(int[] sorts) {

        for (int i = 1; i < sorts.length; i++) {
            boolean flag = true;
            for (int j = 0; j < sorts.length-i; j++) {
                if (sorts[j] > sorts[j+1]){
                    int tmp = sorts[j];
                    sorts[j] = sorts[j+1];
                    sorts[j+1] = tmp;
                    flag = false;
                }
            }
            if(flag){
                break;
            }
        }
        
        return sorts;
    }
}
